home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1998 August / PC Plus SuperCD 50a Issue 142 (CD142a) (August 1998).iso / trial / demon / TURNPIKE.1 / CLASSES.ZIP / JAVA / AWT / Component.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-04-14  |  8.1 KB  |  574 lines

  1. package java.awt;
  2.  
  3. import java.awt.image.ColorModel;
  4. import java.awt.image.ImageObserver;
  5. import java.awt.image.ImageProducer;
  6. import java.awt.peer.ComponentPeer;
  7. import java.io.PrintStream;
  8.  
  9. public abstract class Component implements ImageObserver {
  10.    ComponentPeer peer;
  11.    Container parent;
  12.    // $FF: renamed from: x int
  13.    int field_0;
  14.    // $FF: renamed from: y int
  15.    int field_1;
  16.    int width;
  17.    int height;
  18.    Color foreground;
  19.    Color background;
  20.    Font font;
  21.    boolean visible = true;
  22.    boolean enabled = true;
  23.    boolean valid = false;
  24.  
  25.    Component() {
  26.    }
  27.  
  28.    public Container getParent() {
  29.       return this.parent;
  30.    }
  31.  
  32.    public ComponentPeer getPeer() {
  33.       return this.peer;
  34.    }
  35.  
  36.    public Toolkit getToolkit() {
  37.       ComponentPeer var1 = this.peer;
  38.       if (var1 != null) {
  39.          return var1.getToolkit();
  40.       } else {
  41.          Container var2 = this.parent;
  42.          return var2 != null ? ((Component)var2).getToolkit() : Toolkit.getDefaultToolkit();
  43.       }
  44.    }
  45.  
  46.    public boolean isValid() {
  47.       return this.peer != null && this.valid;
  48.    }
  49.  
  50.    public boolean isVisible() {
  51.       return this.visible;
  52.    }
  53.  
  54.    public boolean isShowing() {
  55.       if (this.visible && this.peer != null) {
  56.          Container var1 = this.parent;
  57.          return var1 == null || ((Component)var1).isShowing();
  58.       } else {
  59.          return false;
  60.       }
  61.    }
  62.  
  63.    public boolean isEnabled() {
  64.       return this.enabled;
  65.    }
  66.  
  67.    public Point location() {
  68.       return new Point(this.field_0, this.field_1);
  69.    }
  70.  
  71.    public Dimension size() {
  72.       return new Dimension(this.width, this.height);
  73.    }
  74.  
  75.    public Rectangle bounds() {
  76.       return new Rectangle(this.field_0, this.field_1, this.width, this.height);
  77.    }
  78.  
  79.    public synchronized void enable() {
  80.       if (!this.enabled) {
  81.          this.enabled = true;
  82.          if (this.peer != null) {
  83.             this.peer.enable();
  84.          }
  85.       }
  86.  
  87.    }
  88.  
  89.    public void enable(boolean var1) {
  90.       if (var1) {
  91.          this.enable();
  92.       } else {
  93.          this.disable();
  94.       }
  95.    }
  96.  
  97.    public synchronized void disable() {
  98.       if (this.enabled) {
  99.          this.enabled = false;
  100.          if (this.peer != null) {
  101.             this.peer.disable();
  102.          }
  103.       }
  104.  
  105.    }
  106.  
  107.    public synchronized void show() {
  108.       if (!this.visible) {
  109.          this.visible = true;
  110.          if (this.peer != null) {
  111.             this.peer.show();
  112.             if (this.parent != null) {
  113.                this.parent.invalidate();
  114.             }
  115.          }
  116.       }
  117.  
  118.    }
  119.  
  120.    public void show(boolean var1) {
  121.       if (var1) {
  122.          this.show();
  123.       } else {
  124.          this.hide();
  125.       }
  126.    }
  127.  
  128.    public synchronized void hide() {
  129.       if (this.visible) {
  130.          this.visible = false;
  131.          if (this.peer != null) {
  132.             this.peer.hide();
  133.             if (this.parent != null) {
  134.                this.parent.invalidate();
  135.             }
  136.          }
  137.       }
  138.  
  139.    }
  140.  
  141.    public Color getForeground() {
  142.       Color var1 = this.foreground;
  143.       if (var1 != null) {
  144.          return var1;
  145.       } else {
  146.          Container var2 = this.parent;
  147.          return var2 != null ? ((Component)var2).getForeground() : null;
  148.       }
  149.    }
  150.  
  151.    public synchronized void setForeground(Color var1) {
  152.       this.foreground = var1;
  153.       if (this.peer != null) {
  154.          var1 = this.getForeground();
  155.          if (var1 != null) {
  156.             this.peer.setForeground(var1);
  157.          }
  158.       }
  159.  
  160.    }
  161.  
  162.    public Color getBackground() {
  163.       Color var1 = this.background;
  164.       if (var1 != null) {
  165.          return var1;
  166.       } else {
  167.          Container var2 = this.parent;
  168.          return var2 != null ? ((Component)var2).getBackground() : null;
  169.       }
  170.    }
  171.  
  172.    public synchronized void setBackground(Color var1) {
  173.       this.background = var1;
  174.       if (this.peer != null) {
  175.          var1 = this.getBackground();
  176.          if (var1 != null) {
  177.             this.peer.setBackground(var1);
  178.          }
  179.       }
  180.  
  181.    }
  182.  
  183.    public Font getFont() {
  184.       Font var1 = this.font;
  185.       if (var1 != null) {
  186.          return var1;
  187.       } else {
  188.          Container var2 = this.parent;
  189.          return var2 != null ? ((Component)var2).getFont() : null;
  190.       }
  191.    }
  192.  
  193.    public synchronized void setFont(Font var1) {
  194.       this.font = var1;
  195.       if (this.peer != null) {
  196.          var1 = this.getFont();
  197.          if (var1 != null) {
  198.             this.peer.setFont(var1);
  199.          }
  200.       }
  201.  
  202.    }
  203.  
  204.    public synchronized ColorModel getColorModel() {
  205.       return this.peer == null ? this.getToolkit().getColorModel() : this.peer.getColorModel();
  206.    }
  207.  
  208.    public void move(int var1, int var2) {
  209.       this.reshape(var1, var2, this.width, this.height);
  210.    }
  211.  
  212.    public void resize(int var1, int var2) {
  213.       this.reshape(this.field_0, this.field_1, var1, var2);
  214.    }
  215.  
  216.    public void resize(Dimension var1) {
  217.       this.reshape(this.field_0, this.field_1, var1.width, var1.height);
  218.    }
  219.  
  220.    public synchronized void reshape(int var1, int var2, int var3, int var4) {
  221.       boolean var5 = this.width != var3 || this.height != var4;
  222.       if (var5 || this.field_0 != var1 || this.field_1 != var2) {
  223.          this.field_0 = var1;
  224.          this.field_1 = var2;
  225.          this.width = var3;
  226.          this.height = var4;
  227.          if (this.peer != null) {
  228.             this.peer.reshape(var1, var2, var3, var4);
  229.             if (var5) {
  230.                this.invalidate();
  231.             }
  232.  
  233.             if (this.parent != null && this.parent.valid) {
  234.                this.parent.invalidate();
  235.             }
  236.          }
  237.       }
  238.  
  239.    }
  240.  
  241.    public Dimension preferredSize() {
  242.       ComponentPeer var1 = this.peer;
  243.       return var1 != null ? var1.preferredSize() : this.minimumSize();
  244.    }
  245.  
  246.    public Dimension minimumSize() {
  247.       ComponentPeer var1 = this.peer;
  248.       return var1 != null ? var1.minimumSize() : this.size();
  249.    }
  250.  
  251.    public void layout() {
  252.    }
  253.  
  254.    public void validate() {
  255.       if (!this.valid && this.peer != null) {
  256.          this.layout();
  257.          this.valid = true;
  258.       }
  259.  
  260.    }
  261.  
  262.    public void invalidate() {
  263.       this.valid = false;
  264.       if (this.parent != null && this.parent.valid) {
  265.          this.parent.invalidate();
  266.       }
  267.  
  268.    }
  269.  
  270.    public Graphics getGraphics() {
  271.       ComponentPeer var1 = this.peer;
  272.       return var1 != null ? var1.getGraphics() : null;
  273.    }
  274.  
  275.    public FontMetrics getFontMetrics(Font var1) {
  276.       ComponentPeer var2 = this.peer;
  277.       return var2 != null ? var2.getFontMetrics(var1) : this.getToolkit().getFontMetrics(var1);
  278.    }
  279.  
  280.    public void paint(Graphics var1) {
  281.    }
  282.  
  283.    public void update(Graphics var1) {
  284.       var1.setColor(this.getBackground());
  285.       var1.fillRect(0, 0, this.width, this.height);
  286.       var1.setColor(this.getForeground());
  287.       this.paint(var1);
  288.    }
  289.  
  290.    public void paintAll(Graphics var1) {
  291.       ComponentPeer var2 = this.peer;
  292.       if (this.visible && var2 != null) {
  293.          this.validate();
  294.          var2.paint(var1);
  295.       }
  296.  
  297.    }
  298.  
  299.    public void repaint() {
  300.       this.repaint(0L, 0, 0, this.width, this.height);
  301.    }
  302.  
  303.    public void repaint(long var1) {
  304.       this.repaint(var1, 0, 0, this.width, this.height);
  305.    }
  306.  
  307.    public void repaint(int var1, int var2, int var3, int var4) {
  308.       this.repaint(0L, var1, var2, var3, var4);
  309.    }
  310.  
  311.    public void repaint(long var1, int var3, int var4, int var5, int var6) {
  312.       ComponentPeer var7 = this.peer;
  313.       if (var7 != null && var5 > 0 && var6 > 0) {
  314.          var7.repaint(var1, var3, var4, var5, var6);
  315.       }
  316.  
  317.    }
  318.  
  319.    public void print(Graphics var1) {
  320.       this.paint(var1);
  321.    }
  322.  
  323.    public void printAll(Graphics var1) {
  324.       ComponentPeer var2 = this.peer;
  325.       if (this.visible && var2 != null) {
  326.          this.validate();
  327.          var2.print(var1);
  328.       }
  329.  
  330.    }
  331.  
  332.    public boolean imageUpdate(Image var1, int var2, int var3, int var4, int var5, int var6) {
  333.       int var7 = -1;
  334.       if ((var2 & 48) != 0) {
  335.          var7 = 0;
  336.       } else if ((var2 & 8) != 0) {
  337.          String var8 = System.getProperty("awt.image.incrementaldraw");
  338.          if (var8 == null || var8.equals("true")) {
  339.             String var9 = System.getProperty("awt.image.redrawrate");
  340.  
  341.             try {
  342.                var7 = var9 != null ? Integer.parseInt(var9, 10) : 100;
  343.                if (var7 < 0) {
  344.                   var7 = 0;
  345.                }
  346.             } catch (Exception var10) {
  347.                var7 = 100;
  348.             }
  349.          }
  350.       }
  351.  
  352.       if (var7 >= 0) {
  353.          this.repaint((long)var7, 0, 0, this.width, this.height);
  354.       }
  355.  
  356.       return (var2 & 160) == 0;
  357.    }
  358.  
  359.    public Image createImage(ImageProducer var1) {
  360.       ComponentPeer var2 = this.peer;
  361.       return var2 != null ? var2.createImage(var1) : this.getToolkit().createImage(var1);
  362.    }
  363.  
  364.    public Image createImage(int var1, int var2) {
  365.       ComponentPeer var3 = this.peer;
  366.       return var3 != null ? var3.createImage(var1, var2) : null;
  367.    }
  368.  
  369.    public boolean prepareImage(Image var1, ImageObserver var2) {
  370.       return this.prepareImage(var1, -1, -1, var2);
  371.    }
  372.  
  373.    public boolean prepareImage(Image var1, int var2, int var3, ImageObserver var4) {
  374.       ComponentPeer var5 = this.peer;
  375.       return var5 != null ? var5.prepareImage(var1, var2, var3, var4) : this.getToolkit().prepareImage(var1, var2, var3, var4);
  376.    }
  377.  
  378.    public int checkImage(Image var1, ImageObserver var2) {
  379.       return this.checkImage(var1, -1, -1, var2);
  380.    }
  381.  
  382.    public int checkImage(Image var1, int var2, int var3, ImageObserver var4) {
  383.       ComponentPeer var5 = this.peer;
  384.       return var5 != null ? var5.checkImage(var1, var2, var3, var4) : this.getToolkit().checkImage(var1, var2, var3, var4);
  385.    }
  386.  
  387.    public synchronized boolean inside(int var1, int var2) {
  388.       return var1 >= 0 && var1 <= this.width && var2 >= 0 && var2 <= this.height;
  389.    }
  390.  
  391.    public Component locate(int var1, int var2) {
  392.       return this.inside(var1, var2) ? this : null;
  393.    }
  394.  
  395.    public void deliverEvent(Event var1) {
  396.       this.postEvent(var1);
  397.    }
  398.  
  399.    public boolean postEvent(Event var1) {
  400.       ComponentPeer var2 = this.peer;
  401.       if (this.handleEvent(var1)) {
  402.          return true;
  403.       } else {
  404.          if (this instanceof Window) {
  405.             Window var3 = (Window)this;
  406.             if (var3.handleTabEvent(var1)) {
  407.                return true;
  408.             }
  409.          } else {
  410.             Container var4 = this.parent;
  411.             if (var4 != null) {
  412.                var1.translate(this.field_0, this.field_1);
  413.                if (((Component)var4).postEvent(var1)) {
  414.                   return true;
  415.                }
  416.             }
  417.          }
  418.  
  419.          return var2 != null ? var2.handleEvent(var1) : false;
  420.       }
  421.    }
  422.  
  423.    public boolean handleEvent(Event var1) {
  424.       switch (var1.id) {
  425.          case 401:
  426.          case 403:
  427.             return this.keyDown(var1, var1.key);
  428.          case 402:
  429.          case 404:
  430.             return this.keyUp(var1, var1.key);
  431.          case 501:
  432.             return this.mouseDown(var1, var1.x, var1.y);
  433.          case 502:
  434.             return this.mouseUp(var1, var1.x, var1.y);
  435.          case 503:
  436.             return this.mouseMove(var1, var1.x, var1.y);
  437.          case 504:
  438.             return this.mouseEnter(var1, var1.x, var1.y);
  439.          case 505:
  440.             return this.mouseExit(var1, var1.x, var1.y);
  441.          case 506:
  442.             return this.mouseDrag(var1, var1.x, var1.y);
  443.          case 1001:
  444.             return this.action(var1, var1.arg);
  445.          case 1004:
  446.             return this.gotFocus(var1, var1.arg);
  447.          case 1005:
  448.             return this.lostFocus(var1, var1.arg);
  449.          default:
  450.             return false;
  451.       }
  452.    }
  453.  
  454.    public boolean mouseDown(Event var1, int var2, int var3) {
  455.       return false;
  456.    }
  457.  
  458.    public boolean mouseDrag(Event var1, int var2, int var3) {
  459.       return false;
  460.    }
  461.  
  462.    public boolean mouseUp(Event var1, int var2, int var3) {
  463.       return false;
  464.    }
  465.  
  466.    public boolean mouseMove(Event var1, int var2, int var3) {
  467.       return false;
  468.    }
  469.  
  470.    public boolean mouseEnter(Event var1, int var2, int var3) {
  471.       return false;
  472.    }
  473.  
  474.    public boolean mouseExit(Event var1, int var2, int var3) {
  475.       return false;
  476.    }
  477.  
  478.    public boolean keyDown(Event var1, int var2) {
  479.       return false;
  480.    }
  481.  
  482.    public boolean keyUp(Event var1, int var2) {
  483.       return false;
  484.    }
  485.  
  486.    public boolean action(Event var1, Object var2) {
  487.       return false;
  488.    }
  489.  
  490.    public void addNotify() {
  491.       this.valid = false;
  492.    }
  493.  
  494.    public synchronized void removeNotify() {
  495.       if (this.peer != null) {
  496.          this.peer.dispose();
  497.          this.peer = null;
  498.       }
  499.  
  500.    }
  501.  
  502.    public boolean gotFocus(Event var1, Object var2) {
  503.       if (var1.target != this) {
  504.          return false;
  505.       } else {
  506.          if (this.parent != null) {
  507.             this.parent.setFocusOwner(this);
  508.          }
  509.  
  510.          return false;
  511.       }
  512.    }
  513.  
  514.    public boolean lostFocus(Event var1, Object var2) {
  515.       return false;
  516.    }
  517.  
  518.    public void requestFocus() {
  519.       ComponentPeer var1 = this.peer;
  520.       if (var1 != null) {
  521.          var1.requestFocus();
  522.       }
  523.  
  524.    }
  525.  
  526.    public void nextFocus() {
  527.       if (this.parent != null) {
  528.          this.parent.nextFocus(this);
  529.       }
  530.  
  531.    }
  532.  
  533.    protected String paramString() {
  534.       String var1 = this.field_0 + "," + this.field_1 + "," + this.width + "x" + this.height;
  535.       if (!this.valid) {
  536.          var1 = var1 + ",invalid";
  537.       }
  538.  
  539.       if (!this.visible) {
  540.          var1 = var1 + ",hidden";
  541.       }
  542.  
  543.       if (!this.enabled) {
  544.          var1 = var1 + ",disabled";
  545.       }
  546.  
  547.       return var1;
  548.    }
  549.  
  550.    public String toString() {
  551.       return this.getClass().getName() + "[" + this.paramString() + "]";
  552.    }
  553.  
  554.    public void list() {
  555.       this.list(System.out, 0);
  556.    }
  557.  
  558.    public void list(PrintStream var1) {
  559.       this.list(var1, 0);
  560.    }
  561.  
  562.    public void list(PrintStream var1, int var2) {
  563.       for(int var3 = 0; var3 < var2; ++var3) {
  564.          var1.print("  ");
  565.       }
  566.  
  567.       var1.println(this);
  568.    }
  569.  
  570.    boolean tabbable() {
  571.       return false;
  572.    }
  573. }
  574.